#创建一个drive驱动
import os
import sys
from datetime import datetime

from selenium import webdriver
from selenium.webdriver.edge.options import Options

class Driver:
    # 创建一个edge驱动器
    driver = ""
    def __init__(self):
        options = Options()
        self.driver = webdriver.Edge(options=options)
        self.driver.implicitly_wait(10)

    # 截图模块
    def getScreenshot(self):
        dirname = datetime.now().strftime("%Y-%m-%d")
        if not os.path.exists('../images/' + dirname):
            os.mkdir('../images/' + dirname)
        filename = sys._getframe().f_back.f_code.co_name + '-' + datetime.now().strftime("%Y-%m-%d-%H%M%S") + '.png'
        self.driver.save_screenshot(os.path.join('../images/' + dirname, filename))

BlogDriver = Driver()
